﻿@model Himall.Model.SiteSettingsInfo
@{
    ViewBag.CopyRight = false;
}
<div class="login">
    <h3><label id="titleType">绑定</label>@(Model.SiteName)账号</h3>
    <div class="option"><input type="text" class="form-control" placeholder="用户名" id="username" /><i class="glyphicon glyphicon-user"></i></div>
    <div class="option"><input type="password" class="form-control" placeholder="密码" id="password" /><i class="glyphicon glyphicon-lock"></i></div>
    <a class="btn btn-primary btn-block" id="bindBtn">绑 定</a>
    <p id="bindInfo"><i class="glyphicon glyphicon-info-sign"></i> 成功绑定后，即自动绑定微信，不可再更改账号</p>
</div>
<script type="text/javascript">
    $(function () {
        $('.login').css('marginTop', -$('.login').height() / 2);

        var serviceProvider = QueryString('serviceProvider');
        var openId = QueryString('openId');
        var headimgurl = QueryString('headimgurl');
        var appidtype = QueryString('AppidType');
        var method = '/' + areaName + '/Login/BindUser';
        var unionid = QueryString('unionid');
        if (!openId) {//判断是否为信任登录
            $('#titleType').html('登录');
            $('#bindBtn').html('登 录');
            method = '/' + areaName + '/Login';
            $('#bindInfo').hide();
        }

    $('#bindBtn').click(function () {
        var username = $('#username').val();
        var password = $('#password').val();
        if (!username)
            $.dialog.errorTips('请填写用户名');
        else if (!password)
            $.dialog.errorTips('请填写密码');
        else {
            var loading = showLoading();
            $.post(method,
                    { username: username, password: password, serviceProvider: serviceProvider, openId: openId, headimgurl: headimgurl,appidtype:appidtype,unionid:unionid },
                    function (result) {
                        loading.close();
                        if (result.success) {
                            $.dialog.succeedTips($('#titleType').html() + '成功!', function () {
                                var returnUrl = QueryString('returnUrl');
                                if (!returnUrl)
                                    returnUrl = '/' + areaName;
                                location.reload
                                location.replace(decodeURIComponent(returnUrl));
                            });
                        }
                        else
                            $.dialog.alert($('#titleType').html() + '失败!' + result.msg);

                    });
            }
        });
    });
</script>
